package hamster.csustef.acquisition.util;

import java.util.Date;

public class TimeUtil {

    /**
     * 让线程睡到下一个时间周期
     * 假如term = 1000 * 60 * 60 也就是一个小时
     * 现在时间为13:24:00,那么这个方法会让线程睡到14:00:00
      */
    public static long sleep(int term) throws InterruptedException {
        long time = new Date().getTime();
        long waitTime = (term) - time % (term);
        long startTime = time + waitTime;
        Thread.sleep(waitTime);
        return startTime;
    }
}
